package birdsong.client;

import static org.junit.Assert.*;

import org.junit.Test;

public class UserTest {

	User user = new User("test");
	User user2 = new User("test2");
	
	@Test
	public void testUser() {
		User user = new User("test");
		assertNotNull(user);
	}

	@Test
	public void testGetNickname() {
	assertEquals("test", user.getNickname());
	}

	@Test
	public void testFollowedUser() {
		assertFalse(user.isFollowedUser());
		user.setFollowedUser();
		assertTrue(user.isFollowedUser());
	}

	@Test
	public void testFollowingUser() {
		assertFalse(user.isFollowingUser());
		user.setFollowingUser();
		assertTrue(user.isFollowingUser());
	}

	@Test
	public void testStopFollowing() {
		
		user.setFollowedUser();
		assertTrue(user.isFollowedUser());
		user.stopFollowing();
		assertFalse(user.isFollowedUser());
	}

	@Test
	public void testStopFollowingMe() {
		user.setFollowingUser();
		assertTrue(user.isFollowingUser());
		user.stopFollowingMe();
		assertFalse(user.isFollowingUser());
	}

	@Test
	public void testCompareTo() {
		assertEquals(0,user.compareTo(user2));			//false && false || false && false
		user.setFollowedUser();
		assertEquals(-1,user.compareTo(user2));			//true && false || false && false
		user.setFollowingUser();
		assertEquals(-1,user.compareTo(user2));			//true && false || true && false		
		user2.setFollowedUser();	
		assertEquals(-1,user.compareTo(user2));			//true && true || true && false
		user2.setFollowingUser();
		assertEquals(0,user.compareTo(user2));			//true && true || true && true
	}

	@Test
	public void testToString() {
		assertEquals(user.toString(), user.getNickname());								//false && false 
		user.setFollowedUser();	
		assertEquals(user.toString(), user.getNickname() + " ***FWED***");				//true && false 
		user.setFollowingUser();
		assertEquals(user.toString(), user.getNickname() + " *FWED+ING*");				//true && true 
		user.stopFollowing();
		assertEquals(user.toString(), user.getNickname() + " ***FWING**");				//false && true 
	}

}
